__author__ = "yourabi@enginesnippets.com"

from google.appengine.ext import db

# Code to be uploaded. Everything displayed to user will be instance of
# CodeRevision starting at revision 0
class Code(db.Model):
  author = db.UserProperty()
  deleted = db.StringProperty()
  title = db.StringProperty()
  

class CodeRevision(db.Model):
  code = db.ReferenceProperty(Code)
  version = db.IntegerProperty()
  content = db.TextProperty(required=True)
  author = db.UserProperty() # Allow for collaboration, diff user from create
  created = db.DateTimeProperty(auto_now_add=True)

class Comment(db.Model):
  code = db.ReferenceProperty(Code)
  text = db.TextProperty()
  user = db.UserProperty()


# Users of EngineSnippets.com
class User(db.Model):
  user = db.UserProperty() # Google Account Authentication/Authorization
  joined = db.DateTimeProperty(auto_now_add=True)
  avatar = db.BlobProperty() # Image Binary Data
  feed = db.StringProperty()

class BugTicket(db.Model):
  code = db.ReferenceProperty(Code)
  created = db.DateTimeProperty(auto_now_add=True)
  closed = db.DateTimeProperty()
  status = db.StringProperty()

class BugTicketComment(db.Model):
  bug_ticket = db.ReferenceProperty(BugTicket)

